package com.shamine.kuaiqiao.blink.basic

import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.widget.Toast
import com.shamine.kuaiqiao.blink.tools.NetworkTool
import dmax.dialog.SpotsDialog
import com.shamine.kuaiqiao.blink.R
import com.shamine.kuaiqiao.blink.events.EventSignOut

/**
 * Created by caine on 11/11/17.
 */
abstract class BaseActivity: AppCompatActivity() {

    private lateinit var dialog: Dialog

    fun getDialog(context: Context): Dialog{
        dialog = SpotsDialog(context, R.style.DialogWait)
        return dialog
    }
    /**
     * 跳转方法
     */
    fun goTo(cls: Class<*>, finish: Boolean) {
        val intent = Intent(this, cls)
        startActivity(intent)
        if (finish) finish()
    }

    /**
     * 检查网络连接
     */
    fun isConnected(): Boolean {
        return NetworkTool().isConnected(applicationContext)
    }
    /**
     * 带intent跳转
     */
    fun goTo(intent: Intent, finish: Boolean){
        startActivity(intent)
        if (finish) finish()
    }

    /**
     *显示通知
     */
    fun toast(context: Context, msg: String){
        Toast.makeText(context,msg, Toast.LENGTH_LONG).show()
    }

    /**
     * 退出登陆
     */
    abstract fun onSignOut(event: EventSignOut)

//
//    /**
//     * 暂停加载
//     */
//    fun pauseRequest(){
//        GlideApp.with(applicationContext).pauseRequests()
//    }
//    /**
//     * 恢复加载
//     */
//    fun resumeRequest(){
//        GlideApp.with(applicationContext).pauseRequests()
//    }
}